<%
  applications = admin_user.applications

  if params[:application]
    applications.reject! { |a| a.parameterize != params[:application] }
  end
%>

<div class="col-md-12">

  <h2><%= t('typus.dashboard.title') %></h2>

  <% if applications.any? %>
    <% applications.each do |app| %>

      <table class="table">

        <thead>
          <tr>
            <th><%= t("typus.application.#{app.parameterize('_')}", default: app) %></th>
          </tr>
        </thead>

        <% admin_user.application(app).map(&:constantize).each do |klass| %>
          <% unless klass.typus_options_for(:hide_from_dashboard) %>
            <tr>
              <td>
                <%= link_to klass.model_name.human(count: 1_000), controller: "/admin/#{klass.to_resource}" %>
              </td>
            </tr>
          <% end %>
        <% end %>

      </table>

    <% end %>
  <% else %>
    <div class="notice">
      <%= t('typus.dashboard.no_applications') %>
    </div>
  <% end %>

</div>
